<?php
require_once("lib/api.php");
require_once("res/const.php");
$api = new api();

if (isset($_GET['postid'])) {
	$postid = $_GET['postid'];
	if (!is_numeric($postid)) {
		$api->setYouFail("Needs to be a number.");
	} elseif (!($postid > 0)) {
		$api->setYouFail("Needs to be a number larger than 0.");
	} else {
		require_once("lib/comment/view.php");
		if ($res = getCommentsForPost($_GET['postid'])) {
			$api->setOk();
			$api->setReturn("comments", $res);
		} else {
			$api->setFail("No comments found for post.");
		}
	}
}
$api->returnResponse();

?>